package com.ruoyi.jiajia.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaTousuConfig;
import com.ruoyi.system.service.IJiajiaTousuConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 投诉举报原因Controller
 * 
 * @author knd
 * @date 2021-11-04
 */
@Controller
@RequestMapping("/jiajia/touSuConfig")
public class JiajiaTousuConfigController extends BaseController
{
    private String prefix = "jiajia/touSuConfig";

    @Autowired
    private IJiajiaTousuConfigService jiajiaTousuConfigService;

    @RequiresPermissions("jiajia:touSuConfig:view")
    @GetMapping()
    public String touSuConfig()
    {
        return prefix + "/touSuConfig";
    }

    /**
     * 查询投诉举报原因列表
     */
    @RequiresPermissions("jiajia:touSuConfig:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaTousuConfig jiajiaTousuConfig)
    {
        startPage();
        List<JiajiaTousuConfig> list = jiajiaTousuConfigService.selectJiajiaTousuConfigList(jiajiaTousuConfig);
        return getDataTable(list);
    }

    /**
     * 导出投诉举报原因列表
     */
    @RequiresPermissions("jiajia:touSuConfig:export")
    @Log(title = "投诉举报原因", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaTousuConfig jiajiaTousuConfig)
    {
        List<JiajiaTousuConfig> list = jiajiaTousuConfigService.selectJiajiaTousuConfigList(jiajiaTousuConfig);
        ExcelUtil<JiajiaTousuConfig> util = new ExcelUtil<JiajiaTousuConfig>(JiajiaTousuConfig.class);
        return util.exportExcel(list, "投诉举报原因数据");
    }

    /**
     * 新增投诉举报原因
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存投诉举报原因
     */
    @RequiresPermissions("jiajia:touSuConfig:add")
    @Log(title = "投诉举报原因", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaTousuConfig jiajiaTousuConfig)
    {
        return toAjax(jiajiaTousuConfigService.insertJiajiaTousuConfig(jiajiaTousuConfig));
    }

    /**
     * 修改投诉举报原因
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaTousuConfig jiajiaTousuConfig = jiajiaTousuConfigService.selectJiajiaTousuConfigById(id);
        mmap.put("jiajiaTousuConfig", jiajiaTousuConfig);
        return prefix + "/edit";
    }

    /**
     * 修改保存投诉举报原因
     */
    @RequiresPermissions("jiajia:touSuConfig:edit")
    @Log(title = "投诉举报原因", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaTousuConfig jiajiaTousuConfig)
    {
        return toAjax(jiajiaTousuConfigService.updateJiajiaTousuConfig(jiajiaTousuConfig));
    }

    /**
     * 删除投诉举报原因
     */
    @RequiresPermissions("jiajia:touSuConfig:remove")
    @Log(title = "投诉举报原因", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaTousuConfigService.deleteJiajiaTousuConfigByIds(ids));
    }
}
